<template>
  <div class="widget-config">
    <el-form
            label-suffix="："
            v-if="this.data && Object.keys(this.data).length > 0"
            labelPosition="right"
            labelWidth="100px"
    >
      <el-collapse v-model="collapse"  @change="handleChangeCollapse">
        <el-collapse-item name="0" title="简单属性" >
          <el-form-item label="标题">
            <el-input v-model="data.label" clearable placeholder="标题"  @input="handleInput"></el-input>
          </el-form-item>

          <el-form-item label="获取变量"   v-if="['input', 'textarea', 'number', 'select'].includes(data.type)&&!data.value">
            <el-select v-model="data.sysParam" placeholder="获取变量" clearable     @change="handleDefValue">
              <el-option label="登录人主键" value="{@{userId}}"></el-option>
              <el-option label="登录人登录名" value="{@{loginName}}"></el-option>
              <el-option label="登录人姓名" value="{@{displayName}}"></el-option>
              <el-option label="登录人手机号" value="{@{phone}}"></el-option>
              <el-option label="登录人租户主键" value="{@{tenantId}}"></el-option>
              <el-option label="登录人租户名称" value="{@{tenantName}}"></el-option>
              <el-option label="登录人角色主键" value="{@{roleId}}"></el-option>
              <el-option label="登录人角色名称" value="{@{roleName}}"></el-option>
              <el-option label="登录人角色性别" value="{@{sex}}"></el-option>
              <el-option label="登录人角色头像" value="{@{avatar}}"></el-option>
              <el-option label="登录人角色邮箱" value="{@{email}}"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item
                  v-if="!['color', 'dynamic', 'group', 'ueditor', 'upload', 'map'].includes(data.type) && !data.sysParam"
                  label="默认值"

          >
            <template v-if="defaultValues && defaultValues[data.type]">
              <el-select v-model="data.value" allow-create clearable filterable placeholder="默认值">
                <el-option
                        v-for="item in defaultValues[data.type]"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                ></el-option>
              </el-select>
            </template>
            <template v-else>
              <el-input v-model="data.value" clearable placeholder="默认值"></el-input>
            </template>
          </el-form-item>


          <el-form-item label="唯一校验">
            <el-switch v-model="data.unique"  @change="handleUniqueSwitchChange"></el-switch>
          </el-form-item>

            <el-form-item label="是否必填">
                <el-switch v-model="data.required"></el-switch>
                <el-input v-if="data.required" v-model.lazy="data.pattern" placeholder="正则表达式"></el-input>
            </el-form-item>

          <el-form-item label="表单栅格" v-if="!data.subfield ">
            <el-input-number
                    style="width:100%;"
                    v-model="data.span"
                    controls-position="right"
                    placeholder="表单栅格"
                    :min="6"
                    :max="24"
            ></el-input-number>
          </el-form-item>

          <component :is="getComponent" :data="data" v-if="['select','radio','checkbox'].includes(data.type)"
                     :widgetForm="form"
                     v-bind="$attrs"
                     v-on="$listeners"
          ></component>


        </el-collapse-item>
        <el-collapse-item name="1" title="基本属性" >
          <el-form-item label="类型" v-if="data.type && !data.component" >
            <el-select
                    v-model="data.type"
                    style="width:100%;"
                    placeholder="请选择类型"
                    @change="handleChangeType"
                    disabled="true"
            >
              <el-option-group v-for="group in fields" :key="group.title" :label="group.title">
                <el-option
                        v-for="item in group.list"
                        :key="item.type"
                        :label="item.label"
                        :value="item.type"
                ></el-option>
              </el-option-group>
            </el-select>
          </el-form-item>
          <el-form-item label="标题">
            <el-input v-model="data.label" clearable placeholder="标题"  @input="handleInput"></el-input>
          </el-form-item>
          <el-form-item label="属性值">
            <el-input v-model="data.prop" clearable placeholder="属性值"></el-input>
          </el-form-item>

          <el-form-item label="获取变量"   v-if="['input', 'textarea', 'number', 'select'].includes(data.type) &&!data.value">
            <el-select v-model="data.sysParam" placeholder="获取变量" clearable     @change="handleDefValue">
              <el-option label="登录人主键" value="{@{userId}}"></el-option>
              <el-option label="登录人登录名" value="{@{loginName}}"></el-option>
              <el-option label="登录人姓名" value="{@{displayName}}"></el-option>
              <el-option label="登录人手机号" value="{@{phone}}"></el-option>
              <el-option label="登录人租户主键" value="{@{tenantId}}"></el-option>
              <el-option label="登录人租户名称" value="{@{tenantName}}"></el-option>
              <el-option label="登录人角色主键" value="{@{roleId}}"></el-option>
              <el-option label="登录人角色名称" value="{@{roleName}}"></el-option>
              <el-option label="登录人角色性别" value="{@{sex}}"></el-option>
              <el-option label="登录人角色头像" value="{@{avatar}}"></el-option>
              <el-option label="登录人角色邮箱" value="{@{email}}"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="组合校验">
            <el-switch v-model="data.groupunique" ></el-switch>
          </el-form-item>
          <el-form-item label="唯一校验">
            <el-switch v-model="data.unique" @change="handleUniqueSwitchChange"></el-switch>
          </el-form-item>


          <el-form-item
                  v-if="!['color', 'dynamic', 'group', 'ueditor', 'upload', 'map'].includes(data.type) && !data.sysParam"
                  label="默认值"
          >
            <template v-if="defaultValues && defaultValues[data.type]">
              <el-select v-model="data.value" allow-create clearable filterable placeholder="默认值">
                <el-option
                        v-for="item in defaultValues[data.type]"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                ></el-option>
              </el-select>
            </template>
            <template v-else>
              <el-input v-model="data.value" clearable placeholder="默认值"></el-input>
            </template>
          </el-form-item>


          <el-form-item label="正则校验："  v-if="['input', 'textarea'].includes(data.type)">
            <el-select
                    size="small"
                    v-model="data.pattern"
                    filterable
                    allow-create
                    default-first-option
                    placeholder="正则表达式"
                    clearable
            >
              <el-option
                      v-for="item in patternType"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="正则校验错误提示："  v-if="['input', 'textarea'].includes(data.type) && data.pattern">
            <el-input v-model="data.patternMsg" clearable placeholder="正则校验错误提示"></el-input>
          </el-form-item>

          <el-form-item label="正则校验事件" v-if="['input', 'textarea'].includes(data.type) && data.pattern">
            <el-select v-model="data.patternEvent" placeholder="正则校验事件" clearable>
              <el-option label="焦点离开" value="blur"></el-option>
              <el-option label="值改变" value="change"></el-option>
            </el-select>
          </el-form-item>

        </el-collapse-item>

        <el-collapse-item name="2" title="样式属性">

          <el-form-item label="标签宽度" v-if="!['group', 'dynamic', 'title'].includes(data.type)">
            <el-input-number
                    v-model="data.labelWidth"
                    :min="0"
                    :step="10"
                    controls-position="right"
                    placeholder="标签宽度"
            ></el-input-number>
          </el-form-item>
          <el-form-item label="标签位置" v-if="!data.subfield">
            <el-select v-model="data.labelPosition" placeholder="标签位置" clearable>
              <el-option label="上" value="top"></el-option>
              <el-option label="左" value="left"></el-option>
              <el-option label="右" value="right"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="宽度" v-if="data.subfield">
            <el-input-number
                    style="width:100%;"
                    v-model="data.width"
                    controls-position="right"
                    placeholder="宽度"
                    :min="100"
            ></el-input-number>
          </el-form-item>
          <el-form-item label="栅格偏移量" v-if="!data.subfield ">
            <el-input-number
                    style="width:100%;"
                    v-model="data.offset"
                    controls-position="right"
                    placeholder="栅格偏移量"
                    :min="0"
                    :max="23"
            ></el-input-number>
          </el-form-item>
          <el-form-item label="表单栅格" v-if="!data.subfield ">
            <el-input-number
                    style="width:100%;"
                    v-model="data.span"
                    controls-position="right"
                    placeholder="表单栅格"
                    :min="6"
                    :max="24"
            ></el-input-number>
          </el-form-item>
          <el-form-item
                  label="数据类型"
                  v-if="['cascader', 'checkbox', 'radio', 'select', 'tree', 'upload', 'img', 'array', 'slider', 'timerange', 'daterange', 'datetimerange'].includes(data.type)"
          >
            <template #label>
              <el-link
                      :underline="false"
                      href="https://avuejs.com/docs/datatype.html"
                      target="_blank"
              >
                数据类型
                <el-icon>
                  <question-filled></question-filled>
                </el-icon>
              </el-link>
            </template>
            <el-select v-model="data.dataType" placeholder="数据类型" clearable>
              <el-option label="String" value="string"></el-option>
              <el-option label="Number" value="number"></el-option>
              <el-option label="Array" value="array"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="字段提示">
            <template #label>
              字段提示
              <el-icon>
                <question-filled></question-filled>
              </el-icon>
            </template>
            <el-input v-model="data.tip" clearable placeholder="字段提示"></el-input>
          </el-form-item>
          <el-form-item
                  v-if="data.tip && !['upload'].includes(data.type)"
                  label="字段提示位置"
                  label-width="110px"
          >
            <el-select v-model="data.tipPlacement" placeholder="字段提示位置" clearable>
              <el-option label="上" value="top"></el-option>
              <el-option label="下" value="bottom"></el-option>
              <el-option label="左" value="left"></el-option>
              <el-option label="右" value="right"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="标题提示">
            <template #label>
              标题提示
              <el-icon>
                <question-filled></question-filled>
              </el-icon>
            </template>
            <el-input v-model="data.labelTip" clearable placeholder="标题提示"></el-input>
          </el-form-item>
          <el-form-item
                  v-if="data.labelTip && !['upload'].includes(data.type)"
                  label="标题提示位置"
                  label-width="110px"
          >
            <el-select v-model="data.labelTipPlacement" placeholder="标题提示位置" clearable>
              <el-option label="上" value="top"></el-option>
              <el-option label="下" value="bottom"></el-option>
              <el-option label="左" value="left"></el-option>
              <el-option label="右" value="right"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="排序" >
            <el-input-number
                    style="width:100%;"
                    v-model="data.order"
                    placeholder="排序"
                    :min="1"
            ></el-input-number>
          </el-form-item>


          <el-form-item label="是否表格" >
            <el-switch v-model="data.isGird"></el-switch>
          </el-form-item>


          <el-form-item label="表格样式" v-if="data.isGird && data.type != 'group'">
            <el-link type="primary"  style="width:50%;">PC端</el-link>
            <el-link type="primary"  style="width:50%;">移动端</el-link>
          </el-form-item>



          <el-form-item label="行" v-if="data.isGird && data.type != 'group'">
            <el-input-number
                    style="width:50%;"
                    v-model="data.rowIndex"
                    placeholder="行"
                    :min="1"
            ></el-input-number>

            <el-input-number
                    style="width:50%;"
                    v-model="data.rowIndexPhone"
                    placeholder="行"
                    :min="1"
            ></el-input-number>

          </el-form-item>

          <el-form-item label="跨行" v-if="data.isGird && data.type != 'group'" >
            <el-input-number
                    style="width:50%;"
                    v-model="data.rowSpan"
                    placeholder="跨行"
                    :min="1"
            ></el-input-number>

            <el-input-number
                    style="width:50%;"
                    v-model="data.rowSpanPhone"
                    placeholder="跨行"
                    :min="1"
            ></el-input-number>

          </el-form-item>

          <el-form-item label="列" v-if="data.isGird && data.type != 'group'">
            <el-input-number
                    style="width:50%;"
                    v-model="data.colIndex"
                    placeholder="列"
                    :min="1"
            ></el-input-number>

            <el-input-number
                    style="width:50%;"
                    v-model="data.colIndexPhone"
                    placeholder="列"
                    :min="1"
            ></el-input-number>
          </el-form-item>

          <el-form-item label="跨列" v-if="data.isGird && data.type != 'group'">
            <el-input-number
                    style="width:50%;"
                    v-model="data.colSpan"
                    placeholder="跨列"
                    :min="1"
            ></el-input-number>

            <el-input-number
                    style="width:50%;"
                    v-model="data.colSpanPhone"
                    placeholder="跨列"
                    :min="1"
            ></el-input-number>
          </el-form-item>




          <el-form-item label="是否单行" v-if="!data.isGird">
            <el-switch v-model="data.row"></el-switch>
          </el-form-item>

          <el-form-item label="详情模式" >
            <el-switch v-model="data.detail"></el-switch>
          </el-form-item>

          <el-form-item label="是否只读">
            <el-switch v-model="data.readonly"></el-switch>
          </el-form-item>

          <el-form-item label="是否禁用">
            <el-switch v-model="data.disabled"></el-switch>
          </el-form-item>
          <el-form-item label="是否可见">
            <el-switch v-model="data.display"></el-switch>
          </el-form-item>

          <el-form-item label="是否必填">
            <el-switch v-model="data.required"></el-switch>
            <el-input v-if="data.required" v-model.lazy="data.pattern" placeholder="正则表达式"></el-input>
          </el-form-item>
          <el-form-item label="不打印">
            <el-switch v-model="data.noprint"></el-switch>
          </el-form-item>
          <el-form-item label="样式名称">
            <el-input v-model="data.className" clearable placeholder="样式名称"></el-input>
          </el-form-item>



        </el-collapse-item>

        <el-collapse-item name="3" title="流程属性">

          <el-form-item label="是否联系人" v-if="['input', 'checkbox','select','userChoose','roleTreeChoose','orgTreeChoose'].includes(data.type)">
            <el-switch v-model="data.isContactPerson"></el-switch>
          </el-form-item>

          <el-form-item
                  label="设为标题"
                  v-if="!data.subfield "
          >
            <el-switch
                    v-model="data.isDataTitle"
            ></el-switch>
          </el-form-item>

          <el-form-item
                  label="设为摘要"
                  v-if="!data.subfield"
          >
            <el-switch v-model="data.isSummary"></el-switch>

          </el-form-item>
          <!-- 是否显示为过程字段 -->
          <el-form-item label="屏蔽过程"
                        v-if="!['dynamic', 'ueditor', 'upload', 'divider', 'hyperLink', 'caption', 'signature'].includes(data.type)">
            <el-switch v-model="data.shieldProcessRecord"></el-switch>
          </el-form-item>
          <!-- 为空只读不显示字段 -->
          <el-form-item label="为空不显示"
                        v-if="!['dynamic', 'divider', 'hyperLink', 'caption','yuyueform'].includes(data.type)">
            <el-switch v-model="data.noDisplayIfNull"></el-switch>
          </el-form-item>
          <el-form-item label="居左布局" v-if="!['dynamic', 'divider', 'ueditor', 'upload', 'signature'].includes(data.type)">
            <el-switch v-model="data.layoutOnLeft"></el-switch>
          </el-form-item>
          <el-form-item label="数据留存"
                        v-if="!['dynamic', 'divider', 'ueditor', 'upload', 'signature','yuyueform'].includes(data.type)">
            <el-tooltip content="动态显隐控制的组件，被隐藏时数据默认会被清空，如需要留存，请开启此功能！" placement="top">
              <el-switch v-model="data.dynamicHideNotClear"></el-switch>
            </el-tooltip>
          </el-form-item>


          <template v-if="['signature'].includes(data.type)">
            <el-divider content-position="left">excel导出参数</el-divider>
            <el-form-item label="起始行">
              <el-input-number v-model="data.excelRow1" placeholder="" />
            </el-form-item>
            <el-form-item label="起始列">
              <el-input-number v-model="data.excelCol1" placeholder="" />
            </el-form-item>
            <el-form-item label="结束行">
              <el-input-number v-model="data.excelRow2" placeholder="" />
            </el-form-item>
            <el-form-item label="结束列">
              <el-input-number v-model="data.excelCol2" placeholder="" />
            </el-form-item>
            <el-form-item label="起始x坐标">
              <el-input-number v-model="data.startX" :max="255" :min="0" placeholder="" />
            </el-form-item>
            <el-form-item label="起始y坐标">
              <el-input-number v-model="data.startY" :max="255" :min="0" placeholder="" />
            </el-form-item>
            <el-form-item label="结束x坐标">
              <el-input-number v-model="data.endX" :max="255" :min="0" placeholder="" />
            </el-form-item>
            <el-form-item label="结束y坐标">
              <el-input-number v-model="data.endY" :max="255" :min="0" placeholder="" />
            </el-form-item>
            <el-divider content-position="left">pdf导出参数</el-divider>
            <el-form-item label="左边距">
              <el-input-number v-model="data.pdfPaddingLeft" placeholder="左边距" />
            </el-form-item>
            <el-form-item label="下边距">
              <el-input-number v-model="data.pdfPaddingBottom" placeholder="下边距" />
            </el-form-item>
            <el-form-item label="宽度">
              <el-input-number v-model="data.pdfImgWidth" placeholder="宽度" />
            </el-form-item>
            <el-form-item label="高度">
              <el-input-number v-model="data.pdfImgHeight" placeholder="高度" />
            </el-form-item>
          </template>




        </el-collapse-item>


        <el-collapse-item name="4" title="组件/数据属性">

          <el-form-item
                  v-if="data.type =='cascader'"
                  label="默认值"
          >
            <template>
              <el-select v-model="data.cascaderType" placeholder="级联类型" clearable  @change="changeCascaderValue($event)">
                <el-option label="默认" value=""></el-option>
                <el-option label="省市区" value="ssq"></el-option>
              </el-select>

            </template>
          </el-form-item>

          <el-form-item label="多选" v-if="['userChoose','roleTreeChoose','orgTreeChoose'].includes(data.type)">
            <el-switch v-model="data.multipleTest"></el-switch>
          </el-form-item>

          <div v-if="['dftable'].includes(data.type)">
            <el-form-item label="应用KEY" >
              <el-input v-model="data.appCode" clearable placeholder="应用KEY"></el-input>
            </el-form-item>
            <el-form-item label="值字段">
              <el-input v-model="data.filedKey" clearable placeholder="值字段"></el-input>
            </el-form-item>
            <el-form-item label="显示字段" >
              <el-input v-model="data.filedLable" clearable placeholder="显示字段"></el-input>
            </el-form-item>
            <el-form-item label="多选" >
              <el-switch v-model="data.multiple"></el-switch>
            </el-form-item>
          </div>

          <component :is="getComponent" :data="data"
                     :widgetForm="form"
                     v-bind="$attrs"
                     v-on="$listeners"
          ></component>
        </el-collapse-item>



        <el-collapse-item name="5" title="事件属性" v-if="!['group'].includes(data.type)">

            <el-card class="box-card2">
              <div slot="header" class="clearfix">
                <span>动态事件</span>
                <el-button style="float: right; padding: 3px 0" type="text" @click="handleAddDynamicEvent">添加列</el-button>
              </div>

            </el-card>
          <div v-for="(ded,index) in data.dynamicEventData" :key="ded" class="text item">
            <li style="margin-bottom: 5px;">
              <el-input
                      style="margin-left: 5px;width: 33%"
                      clearable
                      v-model="ded.linksEventRule"
                      placeholder="级联规则"

              ></el-input>

              <el-select v-model="ded.linksEvent" placeholder="级联事件"    style="margin-left: 5px;width: 20%"  clearable>
                <el-option label="显示" value="1"></el-option>
                <el-option label="隐藏" value="2"></el-option>
                <el-option label="编辑" value="3"></el-option>
                <el-option label="只读" value="4"></el-option>
                <el-option label="数据加载" value="5" disabled></el-option>
                <el-option label="赋值" value="6"></el-option>
              </el-select>

              <el-select v-model="ded.links" placeholder="请选择级联对象" filterable multiple   style="margin-left: 5px;width: 33%">
                <el-option
                        v-for="item in form.column"
                        :key="item.prop"
                        :label="item.label"
                        :value="item.prop">
                </el-option>
              </el-select>

<!--              -->
<!--              <el-input-->
<!--                      clearable-->
<!--                      style="margin-left: 5px;width: 33%"-->
<!--                      v-model="ded.links"-->
<!--                      placeholder="级联对象"-->
<!--              ></el-input>-->

              <el-button
                      style="margin-left: 5px;width: 5%"
                      @click="handleRemoveDynamicEvent(index)"
                      circle
                      plain
                      type="danger"
                      size="small"
                      :icon="Minus"
              >X</el-button>
            </li>
          </div>





<!--          <el-form-item label="级联属性">-->
<!--            <el-input v-model="data.links" clearable placeholder="级联属性"  ></el-input>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="级联事件">-->
<!--            <el-select v-model="data.linksEvent" placeholder="级联事件" clearable>-->
<!--              <el-option label="显隐" value="1"></el-option>-->
<!--              <el-option label="数据加载" value="2" disabled></el-option>-->
<!--              <el-option label="赋值" value="3"></el-option>-->
<!--            </el-select>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="级联规则">-->
<!--            <el-input v-model="data.linksEventRule" clearable placeholder="级联事件规则"  ></el-input>-->
<!--          </el-form-item>-->

          <afd-config-event :data="data"></afd-config-event>

          <!-- 是否触发自定义事件 -->
          <el-form-item label="自定义事件" v-if="
            ![
              'divider',
              'hyperLink',
              'caption',
              'calculator',
              'ueditor',
              'position',
              'area',
              'dynamic',
              'signature',
              'licensePlate',
              'bigdataupload'
            ].includes(data.type)
          ">
            <el-switch v-model="data.customEvent"></el-switch>
          </el-form-item>
          <el-form-item label="事件名" v-if="data.customEvent">
            <el-input placeholder="请输入函数名称" v-model="data.customEventName"></el-input>
          </el-form-item>

        </el-collapse-item>




      </el-collapse>
    </el-form>
    <el-empty v-else description="拖拽字段进行配置" style="margin-top: 90%;"></el-empty>
  </div>
</template>

<script>
  // import { QuestionFilled } from '@element-plus/icons-vue'
  import fields from '../field/index'
  import props from './mixins/props'
  import pinyin from 'js-pinyin'

  import JrQrcode from './my/qrcode.vue';
  import yuyueform from './my/yuyueform.vue';
  import calculator from './my/calculator';
  import { patternType } from '../../utils/index';
  import Draggable from 'vuedraggable';
  import { Operation, Minus, QuestionFilled } from '@element-plus/icons-vue'
  export default {
    name: 'widget-config',
    mixins: [props],
    props: ['defaultValues','form'],
    components: {QuestionFilled ,JrQrcode,yuyueform,calculator},
    computed: {
      getComponent() {

        const prefix = 'afd-config-'
        const { type, component } = this.data

        if ((!type || component) && type != 'ueditor')
          if (['JrQrcode', 'yuyueform','calculator'
          ].includes(type)){
            return type;
          }else{
            return prefix + 'custom'
          }

        let result = 'input'

        if ([undefined, 'input', 'password', 'url'].includes(type)) result = 'input'
        else if ([
          'year', 'month', 'week', 'date', 'datetime', 'time', 'daterange', 'timerange', 'datetimerange', 'dates'
        ].includes(type)) result = 'date'
        else if (['array', 'img'].includes(type)) result = 'array'
        else if (['tree', 'cascader'].includes(type)) result = 'tree'
        else if (['radio', 'checkbox', 'select'].includes(type)) result = 'select'
        else result = type

        return prefix + result
      }
    },
    data() {
      return {
        patternType,
        oldFormTitleExpression: '',
        fields,
        collapse: ['0']
      }
    },
    created() {
      this.$watch('data.collapse', (newValue, oldValue) => {
        this.handleChangeCollapse();
      }, {
        immediate: false,
        deep: true
      });
    },
    methods: {
      handleChangeCollapse(){
        this.data.simpleMode = this.collapse=='0';
      },
        handleUniqueSwitchChange() {
          if(this.data.unique) {
              this.data.required = true;
          }
     },
      handleInput(value) {
        pinyin.setOptions({ checkPolyphone: false, charCase: 1 });
        let ptemp =  pinyin.getCamelChars(value);
        ptemp = ptemp.trim().replace(/^\d+/, '').replace(/[^a-zA-Z0-9]/g, '');
        if(ptemp.length>16) {
          ptemp = ptemp.substr(0, 15);
        }
        let p = "";
        if(this.form.column.length>0){
          p = this.getPropByNum(this.form.column,ptemp,0);
        }
        if(p){
          this.data.prop =p;
        }
      },
      getPropByNum(ls,s,n){
        var str = s+(n?n:'');
        const p = ls.find(l => l.prop ==str)
        if(!p){
          return str;
        }
        return this.getPropByNum(ls,s,n+1);
      },

      //change方法
      changeCascaderValue(value){
        if(this.data.cascaderType == "ssq"){
          this.data.dicData = []
        }
      },
      handleDefValue(){
        this.data.readonly = !!this.data.sysParam
      },
      // 错误比较多隐藏
      handleChangeType(type) {
        if (!type) return
        const config = this.fields.find(f => f.list.find(l => l.type == type))
        if (!config) return
        for (let key in config) {
          if (config && Object.prototype.hasOwnProperty.call(config, key) && !['icon', 'label', 'span'].includes(key)) this.data[key] = config[key]
        }
        let tempprop = this.data.prop;
        this.data.prop = tempprop+"1111";
        this.data.prop = tempprop;

        if(config.format){
          this.data.format = config.format;
        }
        if(config.valueFormat){
          this.data.valueFormat = config.valueFormat;
        }
      },



      handleRemoveDynamicEvent(index) {
        this.data.dynamicEventData.splice(index, 1)
      },
      handleAddDynamicEvent() {

        if(!this.data.dynamicEventData){
          this.data.dynamicEventData = [];
        }
        this.data.dynamicEventData.push({ linksEvent:'1', linksEventRule: '',links:"" })

      },
    }
  }
</script>
